package com.lion.hbase.api;

import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTablePool;
/**
 * 读取hbase配置信息
 * @author 李永曜
 * 2015年6月17日
 */
public class HBaseConfig {

	public static Configuration cfg = null;
	private static final Log logger = LogFactory.getLog(HBaseConfig.class);
	public static HTablePool pool = new HTablePool(HBaseConfiguration.create(), 100);
	static {
		try {
			load("./hbase-site.xml");
		} catch (FileNotFoundException e) {
			logger.error(e);
		} catch (IOException e) {
			logger.error(e);
		}
	}

	public static void load(String path) throws FileNotFoundException,
			IOException {
		if (cfg == null) {
			cfg = HBaseConfiguration.create();
			cfg.addResource(path);
		}
	}

	public static Configuration getConfiguration() {
		return cfg;
	}

}
